package com.java.observer;

public class Test {

    public static void main(String[] args) {

        //初始化主题
        Subject subject = new TeacherSubject();

        //注入观察者
        new StudentObserver("小明", subject);
        new StudentObserver("小明", subject);
        new StudentObserver("小黄", subject);
        new StudentObserver("小李", subject);
        new StudentObserver("小红", subject);
        new StudentObserver("小赵", subject);


        //主题业务变更，同时通知所有观察者
        ((TeacherSubject) subject).setHomework("实现观察者模式");
    }
}
